{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "24a81385",
   "metadata": {},
   "source": [
    "Img Server http://120.26.43.1:9090/static/image/temp.jpg"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "621c663e",
   "metadata": {},
   "source": [
    "获取数据的3种格式\n",
    "1. text 文本\n",
    "2. json 类似字典的形式\n",
    "3. content 字节形式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "6392853c",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "# 从云端‘刨’图片\n",
    "import requests as r\n",
    "#import time\n",
    "#while True:\n",
    "data = r.get('http://120.26.43.1:9090/static/image/temp.jpg').content\n",
    "file = open('temp.jpg','wb') # 创建 + 定义图片文件\n",
    "file.write(data) # 写入数据\n",
    "file.close() # 关闭文件\n",
    "\n",
    "# 人脸检测\n",
    "import cv2\n",
    "dect = cv2.CascadeClassifier('model/face.xml') # 准备分类检测器\n",
    "image = cv2.imread('temp.jpg')\n",
    "image = cv2.flip(image,-1)\n",
    "faces = dect.detectMultiScale(image,1.1,20) # 返回：x,y,w,h\n",
    "\n",
    "cv2.imshow('tempe.jpg',image)\n",
    "cv2.waitKey(0)\n",
    "cv2.destroyAllWindows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b7f790c7",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
